package com.xinan.weixin.msg;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.kit.StringKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

import java.util.List;

@TableBind(tableName = "wx_message")
public class WxMessage extends Model<WxMessage>{
    public static final WxMessage dao = new WxMessage();

    //columns START
    private String ID = "id";  //
    private String MSGTYPE = "msgtype";  //消息类型
    private String TITLE = "title";  //标题
    private String CONTENT = "content";  //文本内容
    private String URL = "url";  //消息链接,音乐链接
    private String HQURL = "hqurl";  //高质量连接
    private String DESCRIPTION = "description";  //关键字描述
    private String PICURL = "picurl";  //图片链接
    private String YXBZ = "yxbz";  //图片链接

    public void setId(int value) {
        set(ID, value);
    }

	public int getId() {
		return get(ID);
	}
    public void setMsgtype(String value) {
        set(MSGTYPE, value);
    }

	public String getMsgtype() {
		return get(MSGTYPE);
	}
    public void setTitle(String value) {
        set(TITLE, value);
    }

	public String getTitle() {
		return get(TITLE);
	}
    public void setContent(String value) {
        set(CONTENT, value);
    }

	public String getContent() {
		return get(CONTENT);
	}
    public void setUrl(String value) {
        set(URL, value);
    }

	public String getUrl() {
		return get(URL);
	}
    public void setHqurl(String value) {
        set(HQURL, value);
    }

	public String getHqurl() {
		return get(HQURL);
	}
    public void setDescription(String value) {
        set(DESCRIPTION, value);
    }

	public String getDescription() {
		return get(DESCRIPTION);
	}
    public void setPicurl(String value) {
        set(PICURL, value);
    }

	public String getPicurl() {
		return get(PICURL);
	}
	//columns END

    public List<WxMessage> findAll() {
        return find("select * from wx_message");
    }
    /**
     * @param   where
     * @return  Record
     */
    public List<Record> findAlls(String where) {
        String sqlExp = "from wx_message";
        if(StringKit.notBlank(where)){
                sqlExp += " where " + where;
        }
        String order =" order by description";
         return Db.find( "select * "+ sqlExp +order);

    }

    public Page<WxMessage> page(int pageNumber, int pageSize, String where) {
        String sqlExp = "from wx_message";
        if(StringKit.notBlank(where)){
            sqlExp += " where " + where;
        }
        String order =" order by description";

        return paginate(pageNumber, pageSize, "select *", sqlExp+order);
    }


    public String getYXBZ() {
        return YXBZ;
    }

    public void setYXBZ(String YXBZ) {
        this.YXBZ = YXBZ;
    }
}

